//
//	"$Id: WieGandComm.h  2016-02-22 $"
//
//	Description:	韦根接口
//	Revisions:		Year-Month-Day	SVN-Author	Modification
//

#ifndef __WIEGANDCOMM_API_H__
#define __WIEGANDCOMM_API_H__

#include "Types.h"
#include "Defs.h"

#ifdef __cplusplus
extern "C" {
#endif

///韦根协议模式
typedef enum
{
	WieGandMode26 = 26,
	WieGandMode34 = 34,
}WieGandMode;

/// 韦根接口读属性模式
typedef enum
{
	ReadNoBlocK = 0,		///< 非阻塞
	ReadBlocK = 1,			///< 阻塞
}WieGandReadMode;

///韦根接口打开设备参数结构体
typedef struct
{
	WieGandMode openMode;
	int reserved[31];
}WieGandOpenParam;

///韦根接口设置属性参数结构体
typedef struct
{
	WieGandReadMode blockMode;   ///<阻塞方式
	int reserved[31];
}WieGandSetParam;

///韦根接口读属性参数结构体
typedef struct
{
	char *pBuf;				  ///<韦根码缓存
	int len;				  ///<缓存长度
	int reserved[30];
}WieGandReadparam;

/// 韦根接口，512字节
typedef struct WieGandComm
{
	/// 底层似有数据
	void *priv;

	/// 增加接口引用
	///
	/// \param [in] thiz 韦根接口指针
	/// \retval 0 成功
	/// \retval <0失败
	int (*addRef)(struct WieGandComm *thiz);

	/// 释放接口
	///
	/// \param [in] thiz 韦根接口指针
	/// \retval 0 成功
	/// \retval <0失败

	int (*release)(struct WieGandComm *thiz);

	/// 韦根接口数据读取
	///
	/// \param [in] thiz 韦根接口指针
	/// \param [in,out] pParam 读属性参数结构体
	/// \retval = 0 成功
	/// \retval < 0 失败
	int (*readWieGandData)(struct WieGandComm *thiz,WieGandReadparam *pParam);

	/// 韦根接口属性设置
	///
	/// \param [in] thiz 韦根接口指针
	/// \param [in] pParam 属性参数结构体
	/// \retval = 0 成功
	/// \retval < 0 失败
	int (*setWieGandAttr)(struct WieGandComm *thiz,WieGandSetParam *pParam);

	/// 韦根接口功能控制
	///
	/// \param [in] thiz 韦根接口指针
	/// \param [in] state 状态操作 0-关闭 1-打开
	/// \retval = 0 成功
	/// \retval < 0 失败
	int (*setWieGandMode)(struct WieGandComm *thiz,int state);

	/// 保留字节
	int reserved[122];
}WieGandComm;

/// 创建韦根接口
///
/// \param [in] desc，韦根描述指针
/// \param [out] WGcomm，韦根指针的指针
/// \retval 0 成功
/// \retval <0 失败
int PAL_API createWieGandComm(WieGandOpenParam *desc, WieGandComm **WGcomm);

/// 获取韦根接口个数
///
int PAL_API getWieGandCommCount(void);

/// @} end of group
#ifdef __cplusplus
}
#endif

#endif //__WIEGANDCOMM_API_H__

